package org.anderground.editor.gui;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;

import org.anderground.editor.gui.properties.TabbedPropertiesPane;
import org.anderground.editor.gui.view.ActiveMetroView;
import org.anderground.editor.gui.view.MetroView;
import org.anderground.editor.gui.view.android.AndroidDrawerView;
import org.anderground.editor.gui.view.standard.StandardView;
import org.anderground.editor.model.EditorModel;

public class EditorPanel extends JPanel {

	private ActiveMetroView firstView = new StandardView();

	private MetroView secondView = new AndroidDrawerView();

	private final EditorWindowSettings settings = new EditorWindowSettings();
	private final TabbedPropertiesPane properties = new TabbedPropertiesPane();
	private DividedLayout viewDivision, panelDivision;

	public EditorPanel(JFrame parent) {

		JPanel viewsPanel = new JPanel();
		viewDivision = new DividedLayout(firstView, secondView, viewsPanel,
				0.6f, DividedLayout.X_AXIS);
		viewsPanel.setLayout(viewDivision);
		viewsPanel.addMouseMotionListener(viewDivision.new DivisionListener(
				viewsPanel));
		this.setPreferredSize(new Dimension(300, 600));
		panelDivision = new DividedLayout(viewsPanel, properties, this, 0.8f,
				DividedLayout.Y_AXIS);
		this.setLayout(panelDivision);
		this.addMouseMotionListener(panelDivision.new DivisionListener(this));
		properties.setBorder(BorderFactory.createLineBorder(Color.decode("#bbbbcc"), 2));
		firstView.setBorder(BorderFactory.createLineBorder(Color.decode("#bbbbcc"), 2));
		secondView.setBorder(BorderFactory.createLineBorder(Color.decode("#bbbbcc"), 2));

		EditorModel.getInstance().addObserver(firstView);
		EditorModel.getInstance().addObserver(secondView);
		EditorModel.getInstance().addObserver(properties);

		this.firstView.addSelectionListener(properties);
		// this.add(properties);

	}

	public MetroView getFirstView() {
		return firstView;
	}

	public void setFirstView(ActiveMetroView firstView) {
		this.firstView = firstView;
	}

	public MetroView getSecondView() {
		return secondView;
	}

	public void setSecondView(MetroView secondView) {
		this.secondView = secondView;
	}

	public EditorWindowSettings getSettings() {
		return settings;
	}

}
